$ ->
  window.id=0;
  refresh=->
    $.getJSON '/Home/Chat/refresh',{id:window.id},(data)->
      
      return false if data.length==0
      index=data.length-1
      window.id=data[index].id
      $.each data,(k,v)->
        html="<li class='am-comment'>
                  <article class='am-comment'>
                      <a href='#link-to-user-home'>
                          <img src='' alt='' class='am-comment-avatar' width='48' height='48'/>
                      </a>
                      <div class='am-comment-main'>
                          <header class='am-comment-hd'>
                              <!--<h3 class='am-comment-title'>评论标题</h3>-->
                              <div class='am-comment-meta'>
                                  <a href='#link-to-user' class='am-comment-author'>#{v.username}</a>
                                  评论于
                                  <time datetime='2013-07-27T04:54:29-07:00' title='2013年7月27日 下午7:54 格林尼治标准时间+0800'>
                                      #{v.time}
                                  </time>
                              </div>
                          </header>

                          <div class='am-comment-bd'>
                              #{v.content}
                          </div>
                      </div>
                  </article>
              </li>"
        $(".am-comments-list").append html
        $(".am-panel-bd").animate({scrollTop: $(".am-comments-list").height()});
  setInterval(refresh,1000)
  $("#submit").click ->
      $.post '/Home/Chat/store', $(".add_comment").serialize()
      return false;
 

     
      
  
    